//Copyright 2010 Balazs Keri, Imre Keri
//
//This file is part of FireworksCreator.
//
//FireworksCreator is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//FireworksCreator is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with FireworksCreator.  If not, see <http://www.gnu.org/licenses/>.
//
#ifndef _OSGVIEWERWIDGET_H
#define _OSGVIEWERWIDGET_H
//
#include <global.h>
#include <QtOpenGL/QGLWidget>
#include <osgViewer/Viewer>
//
class OSGViewerWidget
:
public QGLWidget
{
public:
   Q_OBJECT
   Q_DISABLE_COPY(OSGViewerWidget)
//construction
public:
   OSGViewerWidget(QWidget *p_parent=0,const char *p_name=0,const QGLWidget *p_share_widget=0,Qt::WindowFlags p_f=0);
   virtual ~OSGViewerWidget();
//data
public:
   osgViewer::GraphicsWindow *get_graphics_window();
   const osgViewer::GraphicsWindow *get_graphics_window()const;
   osgViewer::Viewer *get_viewer();
   const osgViewer::Viewer *get_viewer()const;
protected:
   osg::ref_ptr<osgViewer::GraphicsWindowEmbedded> graphics_window;
   osg::ref_ptr<osgViewer::Viewer> viewer;
//event adaptation
protected:
   void resizeGL(int width,int height);
   void paintGL();
   void keyPressEvent(QKeyEvent *event);
   void keyReleaseEvent(QKeyEvent *event);
   void mousePressEvent(QMouseEvent *event);
   void mouseReleaseEvent(QMouseEvent *event);
   void mouseMoveEvent(QMouseEvent *event);
   void wheelEvent(QWheelEvent *event);
   QTimer update_timer;
};
//
#endif